Skip to main content

Paint mask

Paints mask on the image.

🖼️ Image options and parameters of paintMask method
🎭 Mask options and parameters of paintMask method

This method allows painting a mask on the image or on the mask. It can serve as a good visualization tool to highlight the regions in question. For instance, by painting a mask of each black ROI here, we can highlight all the particles present on the image.

for (const roi of rois) {
const { column, row } = roi.origin;
const mask = roi.getMask();
// This paints blue the mask of a roi.
//Origin of roi needs to be specified for correct
//display.
image = image.paintMask(mask, {
origin: { column, row },
color: [0, 0, 255],
});
}

paintMask in action

Kinds of images compatible with algorithm

Image propertyWhat it meansPossible values
bitDepthnumber of bits per channel[8,16]
componentsnumber of componentsany
alphais alpha channel allowedtrue

Parameters and default values

  • mask

  • options

Options

For image:

PropertyRequiredDefault value
blendnotrue
colornoblack
originno{column:0,row:0}
outno-

For mask:

PropertyRequiredDefault value
valueno1
originno{column:0,row:0}
outno-